import React, { Component } from 'react';
import {
  Platform,
  AppRegistry,
  Text,
  Button,
  View,
} from 'react-native';
import { TabNavigator, StackNavigator } from 'react-navigation';
import SignInPage from '../src/pages/signin';
class RecentChatsScreen extends Component {
  render() {
    return (
      <View>
        <Text>List of recent chats</Text>
        <Button
          onPress={() => this.props.navigation.navigate('Chat', { user: 'ifredom-params' })}
          title="link to chat"
        />
      </View>
    )
  }
}
class AllContactsScreen extends Component {
  render() {
    return <Text>List of all contacts</Text>
  }
}
class ChatScreen extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    title: `Chat with ${navigation.state.params.user}`,
  });
  render() {
    const { params } = this.props.navigation.state;
    const { navigate } = this.props.navigation;
    return (
      <View>
        <Text>Chat with</Text>
        <Button
          onPress={() => navigate('Signin', { user: 'ifreom2' })}
          title="Chat with Signin"
        />
      </View>
    );
  }
}
const MainScreenNavigator = TabNavigator({
  Recent: { screen: RecentChatsScreen },
  All: { screen: AllContactsScreen },
  Signin: { screen: SignInPage },
});

const SimpleApp = StackNavigator({
  Home: { screen: MainScreenNavigator },
  Chat: { screen: ChatScreen },
});
MainScreenNavigator.navigationOptions = {
  title: 'My MainScreenNavigator',
};
// ChatScreen.navigationOptions = {
//   title: 'My ChatScreen',
// };
AppRegistry.registerComponent('xxxx', () => SimpleApp);
